package io.mya.app.commons;

import java.math.BigDecimal;

import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.http.HttpUtil;
import io.mya.app.utils.HttpUtils;
import io.mya.common.utils.R;
import io.mya.modules.sys.entity.SysChargeEntity;
import io.mya.modules.sys.service.SysChargeService;
/**
 * K线转换的公告controller
 * @author shican
 *
 */
@RestController
@RequestMapping("/app/public")
public class StockController {
    @Autowired
	private SysChargeService chargeService;
	/**
	 * 查询平台币手续费
	 * @return
	 */
    @RequestMapping("/ssw")
	public R ssw() {
		//查询下单手续费
    	SysChargeEntity chargeEntity = chargeService.queryObject();
    	BigDecimal charge = chargeEntity.getCharge();
		return R.ok().put("charge", charge);
		
		
	}
	/**
	 * 后台走各种第三方接口  传来的参数是第三方接口的链接地址
	 */
	@RequestMapping("/kiln")
	public R Klin(String url) throws JSONException {
		String requestUrlNo = url;
		 String result2 = HttpUtils.sendGet(requestUrlNo);
		 com.alibaba.fastjson.JSONObject jsStr = com.alibaba.fastjson.JSONObject.parseObject(result2);
        return R.ok().put("result2", jsStr);
		
		
	}
//	/**
//	 * 查询各种最新价
//	 * type:1是火币 2是P网 3是B网               name:币种名称 
//	 * @param type
//	 * @param name
//	 * @return
//	 * @throws JSONException
//	 */
//	@RequestMapping("/stock")
//	public R stock(Integer type,String name) throws JSONException {
//		if(type == 1){
//			String requestUrlNo = "http://api.huobipro.com/market/detail/merged?symbol="+name;
//			String result2 = HttpUtil.get(requestUrlNo,
//					"UTF-8");
//			com.alibaba.fastjson.JSONObject jsStr = com.alibaba.fastjson.JSONObject.parseObject(result2);
//			String data = jsStr.get("tick").toString();
//			org.json.JSONArray stock = new org.json.JSONArray(data);
//			return R.ok().put("stock", stock);
//		}else if(type == 2){
//			return R.ok();
//		}else if(type == 3){
//			return R.ok();
//		}
//		return R.ok();
//		
//		
//	}
}
